%Author: Paul Booth

%Plotter-plots lines easily

%params
%X: x to plot 
%Y: y to plot
%Stitle: title to put at top
%Sxaxis: label of x axis
%Syaxis: label of y axis
%Slegend: labels for legends. Column vector
%Acolors: colors for each y. column vector with each element a row vector
%    of size 3, RGB values between 0 and 1 or rand for random



function plotter( x, y , stitle, sxaxis, syaxis, slegend, acolors)
scrsz = get(0,'ScreenSize');
if (nargin>2)
figure('Name',stitle,'NumberTitle','off',...
    'OuterPosition',[1 30 scrsz(3) scrsz(4)-30]);
else
    figure('Name','Generic Graph. Code by Paul Booth',...
        'NumberTitle','off','OuterPosition',[1 30 scrsz(3) scrsz(4)-30]);
end
if (nargin>6)
    hold on
    num=size(y,2);
    for i=1:num
        if (length(acolors)>=i)
    plot(x,y(:,i), 'Color', acolors(i,:));
        else
            plot(x,y(:,i),'Color', [rand rand rand]);
        end
    end
    hold off
else
    if (nargin>1)
plot(x,y);
    else
        text(0.48,0.9,'HI!','FontSize', 16);
        text(.17, 0.8,'Call plotter from the command line or within a function with arguments','FontSize', 16);
         text(.17, 0.7,'plotter(xvalues, yvalues, title,xlabel, ylabel, legend or [], colors like [1 .5 .5 ; 0 0 0] or [])','FontSize', 16);
    end
end
set(gca,'FontSize',14) 
if (nargin>2)
    title(stitle, 'FontSize', 18);
    if (nargin>4)
        xlabel(sxaxis, 'FontSize', 14);
        ylabel(syaxis, 'FontSize', 14);
    end
end
if (nargin>5&&~isempty(slegend))
    h_legend=legend(slegend);
    set(h_legend,'FontSize',14);
end


end